package com.igeek.javase.ch05.hashmaps;

import java.util.HashMap;

/*
 *@author wangpeng
 *2023/7/17 17:49
 *@description TODO
 */
/**
 * 功能需求：
 *HashMap<User,String>
 * 封装 add(User元素)  添加User时，姓名和密码一致则判定是同一元素，将不予以添加
 */

public class UserTest {
    public static void main(String[] args) {
        HashMap<User,String> userMap = new HashMap<>();
        User user1 = new User("lilei","9999");
        User user2 = new User("hanmeimei","6666");
        User user3 = new User("lilei","9999");
        User user4 = new User("Jim","6666");

        userMap.put(user1,"user1");
        userMap.put(user2,"user2");
        userMap.put(user3,"user3");
        userMap.put(user4,"user4");

        //打印
        System.out.println("添加的最终不同的元素个数为："+userMap.size());
    }
}


